//
//  TripMapViewModel.swift
//  ImGuider X
//
//  Created by 陆涛 on 2018/10/25.
//  Copyright © 2018 imguider. All rights reserved.
//

import UIKit
import JZLocationConverterSwift

class TripMapViewModel: NSObject {
    
    
    var loadDataFinished:(()->Void)?
    var day:Day?
    
    func setupAnns() {
        
        DispatchQueue.global().async {
        
            self.anns = self.day?.calendars?.compactMap({ cal -> TripAnnotion? in
                
                if let coor = cal.coor, cal.pictureArray?.count ?? 0 > 0 {
                    
                    let ann = TripAnnotion(coor: coor)
                    ann.model = cal
                    
                    return ann
                }
                
                return nil
            })
            
            DispatchQueue.main.async {
            
                self.loadDataFinished?()
            }
        }
    }
    
    var anns:[TripAnnotion]?
}

